package com.example.demomybatis.mapper;

import com.example.demomybatis.entity.Course;
import com.example.demomybatis.vo.RequestCoursePr;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface CourseMapper {

//    @Insert("insert into course (course_id,course_name,teacher_id) values (#{courseId},#{courseName},#{teacherId})")
    Integer  addCourse(Course course);

    @Delete("delete from  course where course_id = #{courseId}")
    Integer  deleteCourse(Integer courseId);

//    @Select("select * from course")
//    @Results({
//            @Result(property = "courseId",column = "course_id"),
//            @Result(property = "courseName",column = "course_name"),
//            @Result(property = "teacherId",column = "teacher_id"),
//    })
    List<Course> selectCourse(RequestCoursePr requestCoursePr);


    Integer selectCountCourse (RequestCoursePr requestCoursePr);

    @Select("select * from course where course_id =  #{courseId}")
    @Results({
            @Result(property = "courseId",column = "course_id"),
            @Result(property = "courseName",column = "course_name"),
            @Result(property = "teacherId",column = "teacher_id"),
    })
    Course selectOneCourse(Integer courseId);




    @Update("update course set course_name = #{courseName},teacher_id = #{teacherId} where course_id = #{courseId}")
    Integer  updateCourse(Course course);
}
